package ui.juego.mapamundi

import dominio.datos.Caracteristica
import dominio.ubicaciones.Lugar
import org.uqbar.arena.bindings.PropertyAdapter
import org.uqbar.arena.layout.ColumnLayout
import org.uqbar.arena.layout.VerticalLayout
import org.uqbar.arena.widgets.Button
import org.uqbar.arena.widgets.Label
import org.uqbar.arena.widgets.List
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.widgets.Selector
import org.uqbar.arena.windows.Dialog
import org.uqbar.arena.windows.WindowOwner
import ui.juego.utilidades.IconUtils

class EditarLugarDialog extends Dialog<EditarLugar> {
	
	new(WindowOwner owner, EditarLugar model) {
		super(owner, model)
		title = "Editar Lugares"
		iconImage = IconUtils.path
	}
	
	override protected createFormPanel(Panel mainPanel) {
		var Panel contentPanel = new Panel(mainPanel) => [
			layout = new VerticalLayout
		]
		
		new Label(contentPanel).text = "Lugares: "
		new List<Caracteristica>(contentPanel) => [
			bindItemsToProperty("pais.lugares").adapter = new PropertyAdapter(Lugar, "nombreTipoLugar")
			heigth = 50
			width = 150
			bindValueToProperty("lugarSeleccionado")
		]
		
		new Button(contentPanel) => [
			caption = "Eliminar"
			setAsDefault
			onClick [ |
				modelObject.eliminarLugarSeleccionado
			]
		]
		
		var Panel addPanel = new Panel(contentPanel) => [
			layout = new ColumnLayout(2)
		]
		new Selector(addPanel) => [
			bindItemsToProperty("lugaresPosibles").adapter = new PropertyAdapter(Lugar, "nombreTipoLugar")
			bindValueToProperty("lugarPosibleSeleccionado")
		]
		new Button(addPanel) => [
			caption = "Agregar"
			setAsDefault
			onClick [ |
				modelObject.agregarLugarPosibleSeleccionado
			]
		]
		
		new Button(contentPanel) => [
			caption = "Aceptar"
			onClick [ |
				close
			]
		]
	}
	
}